package engine.data
{
	import engine.GameData;
	import engine.flag.GameDefine;
	import engine.logic.login.LoginLogic;
	import engine.net.datatype.ByteArrayEx;
	
	import flash.events.IEventDispatcher;
	import flash.geom.Point;
	import flash.net.URLRequest;
	import flash.net.navigateToURL;

	//角色VO
	public class RoleVo extends SceneObject
	{
		public function RoleVo(ID:Point, type:uint = 0, modelId:uint = 0, target:IEventDispatcher=null)
		{
			super(ID, type, modelId, target);
		}
		
		/**
		 *	获取声望 
		 * @return 
		 * 
		 */
		public function getPlayerPeerageExp():int
		{
			return GetPropertiesEx( "PeerageExp" );
		}
		
		/**
		 *
		 * 	 获取排名竞技场排名
		 * 
		 */		
		public function getCurAddCloneChallenge():int
		{
			return GetPropertiesEx( "CurAddCloneChallenge" );
		}
		
		/**
		 *	获取玩家点数 
		 * @return 
		 * 
		 */
		public function getPlayerPoint():int
		{
			return GetPropertiesEx( "AccountPoints" );
		}
		
		/**
		 * 玩家种族
		 * @return
		 */
		public function getPlayNation():int
		{
			return GetPropertiesEx("Nation");
		}
		/**
		 * 获得玩家职业
		 */
		public function getPlayerProf():int
		{
			//0战士1法师2牧师3,贼 4骑士 5术士 6猎人 
			return GetPropertiesEx("ProfType");
		}
		
		/**
		 *	获取玩家城堡 
		 * 
		 */		
		public function getPlayerCastle():String
		{
			return GetPropertiesEx("CastleName");
		}
		/**
		 *	获取玩家家族 
		 */		
		public function getPlayerGuild():String
		{
			return GetPropertiesEx("GuildName");
		}
		/**
		 * 玩家性别
		 * @return
		 */
		public function getPlaySex():int
		{
			return GetPropertiesEx("Sex");
		}
		/**
		 * 获得玩家姓名
		 */
		public function getPlayerName():String
		{
			return GetPropertiesEx("Name");	
		}
		
		/**
		 * 获得玩家头像资源路径
		 */
		public function getPlayerHeadPhoto():String
		{
			//return "res/png/" + GetPropertiesEx("Photo") + ".png";
			
			var model : String = GetPropertiesEx("Model");
			return "res/png/6" + model.slice(1, model.length) + ".png";
		}
		
		override public function setPropertiesFormByteArrayEx(count:int, msg:ByteArrayEx):void
		{
			super.setPropertiesFormByteArrayEx(count,msg);
			
			if(GameData.Role == null)
			{
				GameData.CreateRoleModel();
			}
		}
		
		/**
		 * 获得玩家等级
		 */
		public function getPlayerLevel():int
		{
			return GetPropertiesEx("Level");
		}
		
		/**
		 *	获取玩家阵营 
		 */
		public function getPlayerCamp():int
		{
			return GetPropertiesEx("Camp");
		}
		/**
		 *	获取玩家爵位等级
		 */		
		public function getPlayerPeerage():int
		{
			return GetPropertiesEx("PeerageLev");
		}
		/**
		 *	获取玩家人气 
		 */
		public function getPlayerCharm():int
		{
			return GetPropertiesEx("Charm");
		}
		/**
		 *	获取玩家战斗力 
		 */		
		public function getPlayerFightScore():int
		{
			return GetPropertiesEx("FightPower");
		}
		/**
		 * 获得玩家当前hp
		 */
		public function getPlayerHP():int
		{
			return GetPropertiesEx("HP");
		}
		
		/**
		 * 获得玩家hp最大值
		 */
		public function getPlayerMaxHP():int
		{
			return			(GetPropertiesEx("MaxHP") + GetPropertiesEx("MaxHPAdd")) * (1 + (GetPropertiesEx("MaxHPMul") + GetPropertiesEx("MaxHPMulAdd") / 100)
				+GetPropertiesEx("MaxHPBonus") + GetPropertiesEx("MaxHPBonusAdd"));
			// GetPropertiesEx("MaxHP") + GetPropertiesEx("MaxHPAdd");
		}
		
		/**
		 * 获得玩家当前sp
		 */
		public function getPlayerSP():int
		{
			return GetPropertiesEx("SP");
		}
		
		/**
		 * 获得玩家sp最大值
		 */
		public function getPlayerMaxSP():int
		{
			return GetPropertiesEx("MaxSP") + GetPropertiesEx("MaxSPAdd");
		}
		
		/**
		 * 获得玩家当前经验
		 */
		public function getPlayerExp():int
		{
			return GetPropertiesEx("PlayerExp");
		}
		
		/**
		 * 获得当前最大经验值
		 */
		public function getPlayerMaxExp():int
		{
			return GetPropertiesEx("PlayerUpgradeExp");
		}
		
		/**
		 * 根据玩家职业返回mp类型
		 */
		public function getMpType():String
		{
			//职业
			var profType	: int	=	getPlayerProf();
			//根据职业绑定mp
			if(GameDefine.ProfType_Warrior	==	profType)
			{//战士绑定AP
				return "AP";
			}
			else if (GameDefine.ProfType_Rouge 		==	profType ||
				GameDefine.ProfType_Hunter 	==	profType)
			{//盗贼，猎人使用ST
				return "ST";
			}
			else
			{//其他职业使用MP
				return "MP";
			}
		}
		
		/**
		 * 获得玩家当前mp
		 */
		public function getPlayerMP():int
		{
			return GetPropertiesEx(getMpType());
		}
		
		/**
		 * 获得玩家mp最大值
		 */
		public function getPlayerMaxMP():int
		{
			var mpType	:	String	=	getMpType();
			return GetPropertiesEx("Max" + mpType) + GetPropertiesEx("Max" + mpType + "Add");;
		}
		/**
		 *	获取玩家战斗力 
		 */
		public function getPlayerFightPower():int
		{
			return GetPropertiesEx( "TotalFightPower" );
		}
		/**
		 * 获取玩家先功值 
		 * 
		 */		
		public function getSpeedRate():int
		{
			return GetPropertiesEx( "TotalSpeedRateAdd" );
		}
		/**
		 * 取得城堡时代 
		 */
		public function getCastleEra():int
		{
			return ModelLocator.getInstance().scene.GetPropertiesEx("CastleEra");
		}
		
		/**
		 * 获得城堡等级
		 */
		public function getCastleLevel():int
		{
			return ModelLocator.getInstance().scene.GetPropertiesEx("CastleLevel");
		}
		
		/**
		 * 	是否是城堡主
		 */
		public function isCastleMaster():Boolean
		{
			return GetPropertiesEx("CurCastleStatusId") == 10000;
		}
		
		/**
		 *	获得金币 
		 */
		public function getGoldCoin():int
		{
			return GetPropertiesEx( "GoldCoin" );
		}
		
		/**
		 *	获得龙晶币 
		 */
		public function getMagicCoin():int
		{
			return GetPropertiesEx( "MagicCoin" );
		}
		/**
		 * 获取VIP等级
		 */
		public function getVipLevel():int
		{
			return GetPropertiesEx("VIPLevel"); 
		}
		/**
		 * 获取VIP当前经验
		 */
		public function getVipNowExe():int
		{
			return GetPropertiesEx("VIPExp"); 
		}
		/**
		 * 获取VIP升级总经验
		 */
		public function getVipAlwaysExe():int
		{
			return GetPropertiesEx("VIPNextExp");  
		}
		/**
		 * 获取玩家金钱兑换过的次数 
		 * @return 
		 * 
		 */		
		public function getGoldExchangeCount():int
		{
			return GetPropertiesEx("GoldExchangeCount");
		}
		//充值
		public function recharge():void
		{
			var model : ModelLocator = ModelLocator.getInstance();
			//是联运游戏,不是本地游戏
			var str:String = model.mainIni.getContent("ChongZhi","url");
			if( "false" == model.mainIni.getContent("ally","is") )
			{//蜗牛网运营
				str = str +　"&account="+ModelLocator.getInstance().player.sAccount+
					"&serverid="+LoginLogic.ServerID;
			}
			
			var url:URLRequest = new URLRequest(str);
			navigateToURL(url,"_blank");
		}
		/**
		 * 获取时装ID号 
		 * @return 
		 * 
		 */		
		public function get clotheModel():int
		{
			var clothe:int	=	0;
			clothe	=	GetPropertiesEx("ClotheModel");
			clothe	=	clothe ==0?1:clothe;
			return clothe;
		}
	}
}